/*
 * Copyright (c) 2013 Andaily Information Technology Co. Ltd
 * www.andaily.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Andaily Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with Andaily Information Technology Co. Ltd.
 */
package top.suven.http.oauth.validator;

import org.apache.oltu.oauth2.as.request.AbstractOAuthTokenRequest;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 2018-08-01
 * <p/>
 *  OauthAccessToken 信息
 * 定义OAuth2 的客户端(client details)
 *  grant_type="authorization_code"
 *  DBTable: oauth_client_details
 *
 * @author suven.wang
 */
/**
 * /oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=refresh_token&refresh_token=b36f4978-a172-4aa8-af89-60f58abe3ba1
 **/

public class GrantTypeRefreshTokenValidator extends AbstractOauthGrantTypeValidator {

    private static final Logger logger = LoggerFactory.getLogger(GrantTypeRefreshTokenValidator.class);


    public GrantTypeRefreshTokenValidator(AbstractOAuthTokenRequest oauthRequest) {
        super(oauthRequest);
    }

    /*
    * /oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=refresh_token&refresh_token=b36f4978-a172-4aa8-af89-60f58abe3ba1
    * */
    @Override
    protected boolean validateSelf() throws OAuthSystemException {

        // 前4点 基于token 验证于AbstractOauthTokenValidator 抽象
        if(!this.validateGrantType()){
            return false;
        }
        if(!validateRefreshToken()){
            return false;
        }
        return true;
    }






}
